package com.xuxueli.applyModules.entity;

import com.alibaba.fastjson.JSONArray;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

@Data
public class User {

    @ApiModelProperty(value = "主键")
    private String id;
    @ApiModelProperty(value = "名称")
    private String name;
    @ApiModelProperty(value = "所属部门")
    private String dept;
    @ApiModelProperty(value = "签名值")
    private String sign;
    @ApiModelProperty(value = "时间戳")
    private Long timeStamp;
    @ApiModelProperty(value = "报关单编号")
    private BigDecimal entryGNo;
    @ApiModelProperty(value = "金额")
    private BigDecimal amount;
    @ApiModelProperty(value = "金额字符串")
    private String amountStr;
    @ApiModelProperty(value = "序号")
    @JsonProperty("gNo")
    private String gNo;
    @ApiModelProperty(value = "标记")
    private Boolean tempFlag;
    @ApiModelProperty(value = "错误信息")
    private String tempRemark;
    @ApiModelProperty(value = "描述")
    private String description;
    @ApiModelProperty(value = "描述错误信息")
    private String descriptions;
    @ApiModelProperty(value = "统计数")
    private int countSum;
    @ApiModelProperty(value = "执行时间")
    private Date dateTime;
    @ApiModelProperty(value = "创建者")
    private String createBy;
    @ApiModelProperty(value = "创建时间")
    private LocalDateTime createTime;
    //@ApiModelProperty(value = "模拟集合")
    private List<User> list = new ArrayList<>();

    public User() {
    }

    public User(String name, String dept, String sign) {
        this.name = name;
        this.dept = dept;
        this.sign = sign;
    }

    //lombok生成规则有误
    public String getgNo() {
        return gNo;
    }

    public void setgNo(String gNo) {
        this.gNo = gNo;
    }

    //处理form_data数组接受失败
    public void setList(String list) {
        List<User> userList = JSONArray.parseArray(list, User.class);
        this.list = userList;
    }

    public void setDateTime(Long dateTime) {
        Date now = null;
        Calendar calendar = Calendar.getInstance();
        if(null!=dateTime){
            calendar.setTimeInMillis(dateTime);
            now =  calendar.getTime();
        }
        this.dateTime = now;
    }
}
